<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*

switch (ENVIRONMENT) {
	case 'development':
		$color = 'danger';
		break;
	case 'testing':
		$color = 'warning';
		break;
	case 'production':
		$color = 'success';
		break;
	default:
		$color = 'primary';
		break;
}

echo ui_callout('alert-' . $color, 'Type of publication', 'The server is in <span class="text-uppercase"><strong>' . ENVIRONMENT . '</strong></span> mode.');
*/
?>
<!--
<div class="row">
	<div class="col-md-3 col-sm-6 col-xs-12">
		<?php //echo wg_info_box_progress('bg-aqua', '<i class="fa fa-microchip"></i>', 'Memory used', $memory_use, $memory_use_percent, 'Free: ' . $memory_free . ' / Total: ' . $memory_total); ?> 
	</div>	
	<div class="col-md-3 col-sm-6 col-xs-12">
		<?php //echo wg_info_box_progress('bg-aqua', '<i class="fa fa-database"></i>', 'Disk space used', $disk_use, $disk_use_percent, 'Free: ' . $disk_free . ' / Total: ' . $disk_total); ?>
	</div>	
</div>
-->


<div class="row">
  <div class="col-sm-12">
        <div class="box">
          <div class="box-header with-border">
              <!--<a href="/backend/shoppingerror" class="btn btn-flat bg-olive pull-right">广告错误</a>-->
              <h3 class="box-title">询盘统计查询</h3>
          </div>
          <div class="box-body">
          <?php echo form_open(current_url(), array('class' => 'form-inline', 'id' => 'f')); ?>
          <div class="form-group">
                  <label class=" control-label">查询站点</label>
                  
                  <select name="siteid" id="sites" class="form-control" >
                    <option value="0">所有站点</option>
                    <?php
                    foreach($sites as $site)
                    {
                      echo '<option value="'.$site["id"].'">'.$site["name"].'</option>';
                    }?>
                  </select>
                </div>
                <div class="form-group filtercol" id="filtertype1">
                  <label class=" control-label">按时间范围查询</label>
                  
                  <?php echo tpl_form_field_daterange("timelimit",[],false);?>
                 
                </div>

                <div class="form-group">
                                            
                                                <div class="btn-group">

                                                    <?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-sm btn-primary btn-flat', 'content' => '查询')); ?>
                                                  
                                                </div>
                                           
                                        </div>


          <?php echo form_close();?>

          <?php if($result):?>

          <div class="callout callout-success">
                <h4  style="line-height:1.5em;"> <?php echo $result;?></h4>
          </div>

          
          <?php endif;?>
          </div>
        </div>
  </div>
</div>

<div class="row">

        

                        <div class="col-md-12" >
                            <div class="box">
                                <div class="box-header with-border">
                                    <h3 class="box-title">询盘数量</h3>
                                </div>
                                <div class="box-body">
                                    
                                        <div class="chart">
                                            <canvas id="barChart2" style="width:90%;height:330px"></canvas>
                                        </div>
                                    
                                     
                                     <?php

                                        echo "<h5 style='text-align:center;'>15天内共有".$tongji["ordercount"]."次询盘</h5>";
                                     ?>

                                </div>
                            </div>
                        </div>


					</div>
					
<script>
$(document).ready(function() {
    $('#sites').select2();
});
</script>
					<!-- ChartJS -->
<script src="/assets/frameworks/chart.js/Chart.js"></script>
<script>
  $(function () {
    
    var areaChartData2 = {
      labels  : [<?php
              foreach($days as $k=>$day)
              {
                  echo "'{$day}'";
                  if($k<(count($days)-1)) echo ",";
              }
              ?>],
      datasets: [
       
        {
          label               : '询盘数量',
          fillColor           : 'rgba(60,141,188,0.9)',
          strokeColor         : 'rgba(60,141,188,0.8)',
          pointColor          : '#3b8bba',
          pointStrokeColor    : 'rgba(60,141,188,1)',
          pointHighlightFill  : '#fff',
          pointHighlightStroke: 'rgba(60,141,188,1)',
          data                : [<?php
          foreach($odata as $k=>$o)
          {
              echo $o["ordercount"];
              if($k<(count($days)-1)) echo ",";
          }?>]
        }

      ]
    };


    var barChartCanvas2                   = $('#barChart2').get(0).getContext('2d');
    var barChart2                         = new Chart(barChartCanvas2);
    var barChartData2                     = areaChartData2;
    

    barChartData2.datasets[0].fillColor   = '#00a65a';
    barChartData2.datasets[0].strokeColor = '#00a65a';
    barChartData2.datasets[0].pointColor  = '#00a65a';

    var barChartOptions                  = {
      scaleBeginAtZero        : true,
      scaleShowGridLines      : true,
      scaleGridLineColor      : 'rgba(0,0,0,.05)',
      scaleGridLineWidth      : 1,
      scaleShowHorizontalLines: true,
      scaleShowVerticalLines  : true,
      barShowStroke           : true,
      barStrokeWidth          : 2,
      barValueSpacing         : 5,
      barDatasetSpacing       : 1,
      legendTemplate          : '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
      responsive              : true,
      maintainAspectRatio     : true
    };
    barChartOptions.datasetFill = false;
    barChart2.Bar(barChartData2, barChartOptions);
  });
</script>
